package com.codeczx.completeuidemo.glide_confilct;

import android.support.design.widget.BaseTransientBottomBar;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.codeczx.completeuidemo.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by codeczx on 2017/10/17.
 */

public class ListAdapter extends RecyclerView.Adapter {
	
	private List<String> mList;
	
	ListAdapter() {
		mList = new ArrayList<>();
	}
	
	@Override
	public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		return ContentViewHolder.newInstance(parent);
	}
	
	@Override
	public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
		if(holder instanceof ContentViewHolder){
			((ContentViewHolder) holder).bind(mList.get(position));
		}
	}
	
	@Override
	public int getItemCount() {
		return mList == null ? 0 : mList.size();
	}
	
	public static class ContentViewHolder extends RecyclerView.ViewHolder {
		
		@BindView(R.id.tv_item)
		TextView textView;
		private ContentViewHolder(View itemView) {
			super(itemView);
			ButterKnife.bind(this,itemView);
		}
		
		public static ContentViewHolder newInstance(ViewGroup parent){
			return new ContentViewHolder(parent);
		}
		
		public void bind(String text){
			textView.setText(text);
		}
	}
}
